package gamble.qna.vo;

public class PageVO {
	private int currentPage; //현재페이지
	private int totalCount;// 전체 게시물 수
	private int blockCount ; //한 페이지당 보여줄 레코드 수
	private int blockPage; //한 블록당 보여줄 페이지수
	
	private int totalPage; //전체 페이지수
	private int startCount; //한 페이지에서 보여줄 게시글의 시작번호
	private int endCount; //한 페이지에서 보여줄 게시글의 끝번호
	private int startPage; // 블록 시작페이지
	private int endPage; //블록 끝페이지
	private String search;
	//private String search ; //검색어
	
	public PageVO() {
		// TODO Auto-generated constructor stub
	}
	
	
	public PageVO(String search) {
		this.search=search;
	}
	
	public PageVO(int currentPage,int totalCount,
			         int blockCount,int blockPage){
		this.currentPage=currentPage;
		this.totalCount=totalCount;
		this.blockCount=blockCount;
		this.blockPage=blockPage; 
		
		//전체 페이지수
		totalPage=(int)Math.ceil((double)totalCount/blockCount);
		if(totalPage==0)
			totalPage=1;
		
		//현재 페이지의 처음과 마지막 글번호 가져오기
		startCount=(currentPage-1)*blockCount+1;
		endCount=startCount+blockCount-1;
		
		
		//한블록당 보여줄 시작페이지와 끝페이지
		startPage=(int)((currentPage-1)/blockPage)*blockPage+1;
		endPage=startPage+blockPage-1;
		if(endPage>totalPage)
			endPage=totalPage;
		
		
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}

	public int getBlockCount() {
		return blockCount;
	}

	public void setBlockCount(int blockCount) {
		this.blockCount = blockCount;
	}

	public int getBlockPage() {
		return blockPage;
	}

	public void setBlockPage(int blockPage) {
		this.blockPage = blockPage;
	}

	public int getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public int getStartCount() {
		return startCount;
	}

	public void setStartCount(int startCount) {
		this.startCount = startCount;
	}

	public int getEndCount() {
		return endCount;
	}

	public void setEndCount(int endCount) {
		this.endCount = endCount;
	}

	public int getStartPage() {
		return startPage;
	}

	public void setStartPage(int startPage) {
		this.startPage = startPage;
	}

	public int getEndPage() {
		return endPage;
	}

	public void setEndPage(int endPage) {
		this.endPage = endPage;
	}

	
	public String getSearch() {
		return search;
	}

	public void setSearch(String search) {
		this.search = search;
	}	
	
}











